package com.syc.control;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.syc.dao.inter.enitiy.User;
import com.syc.service.inter.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.IOException;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/addAdInfo", method = RequestMethod.POST)
    @ResponseBody
    public User selectPageAdInfo() {
        User user = new User();
        user.setEmail("syc");
        return user;
    }

//
//    @RequestMapping("/showUser.do")
//    public void selectUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
//        request.setCharacterEncoding("UTF-8");
//        response.setCharacterEncoding("UTF-8");
//        long userId = Long.parseLong(request.getParameter("id"));
//        User user = this.userService.selectUser(userId);
//        ObjectMapper mapper = new ObjectMapper();
//        response.getWriter().write(mapper.writeValueAsString(user));
//        response.getWriter().close();
//    }

}
